import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

// src/schemas/users/user.schema.ts
@Schema({ timestamps: true })
export class User extends Document {
  @Prop({ required: true, unique: true, match: /^1[3-9]\d{9}$/ })
  mobile: string;

  @Prop()
  name: string;

  @Prop({ enum: ['male', 'female'] }) // 1男 2女
  gender: string;

  @Prop()
  province: string; // 省份

  @Prop()
  city: string;     // 地市

  @Prop()
  school: string;

  @Prop() // 如2026届
  graduationYear: string;

  // 保留原有字段
  @Prop({ select: false }) password?: string;
  @Prop() smsCode?: string;
  @Prop() smsCodeExpire?: Date;
  @Prop({ type: [String], default: ['USER'] }) roles: string[];
}

export const UserSchema = SchemaFactory.createForClass(User);